<!DOCTYPE HTML>
<html class='mta_wechat'>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>编辑网页测试</title>
	<link rel="stylesheet" href="../css/default.css" />
	<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
	<script charset="utf-8" src="../js/kindeditor.js"></script>
	<script charset="utf-8" src="../js/lang/zh_CN.js"></script>
	<script type="text/javascript">

	
	$(function(){
			var editor;
			$("#J_editorDialog").click(function(){
				editor= KindEditor.create('#content', {
					pasteType : 2
				});
				editor.html("");
			});
			

			$("#getHtml").click(function(){
				var ss = editor.html();
				alert(ss)
				if(IsNotEmpty(ss)){
					$.post("../bussBill/upload/htmlInit", {"htmlStr":ss}, function(data){
						if(IsNotEmpty(data)){
							var rst = JSON.parse(data);
							editor.html("")
						}
					})
				}
				editor.remove('#content');
			});
			
			$("#setHtml").click(function(){
				var url = "http://localhost:8080/transmoo/test/ddd.html";
				if(IsNotEmpty(url)){
					$.get("../bussBill/find/htmlStr",{"htmlUrl":url},function(data){
						 if(IsNotEmpty(data)){
								editor = KindEditor.create('#content', {
								pasteType : 2
							});
							var rst = JSON.parse(data);
	 						if(rst.state == 0){
								var htmlStr = rst.result.data[0];
								if(IsNotEmpty(htmlStr)){
									htmlStr = htmlStr.toString();
							 		editor.html(htmlStr);  
								}
							}else{
								alert(rst.msg)
							} 
						 }
					});
				}
				
/* 				$.ajax({
					type : "post",
					async:false,
					data :{"htmlUrl":url},
					datatype : "text",
					url : "../bussBill/find/htmlStr",
					success : function(data) {
						alert(data)
					}	
				});	 */
			}); 
	});
	

	</script>
</head>
<body>
	<div>
		<textarea id="content" name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>
		<input type="button" id="J_editorDialog"  value="编辑首页">
		<input   type="button"   id="getHtml" value="返回html">
		<input   type="button"   id="setHtml" value="读取html">
	</div>
</body>
</html>
